package pattern.template;

/**
 * double排序
 *
 * @author sun.ye
 * @since 2020-07-15 15:40
 */
public class DoubleBubbleSorter extends AbstractBubbleSorter {
    private double[] array;

    public int sort(double[] array){
        this.array = array;
        length = array.length;
        return doSort();
    }


    @Override
    protected void swap(int index) {
        double temp = array[index];
        array[index] = array[index + 1];
        array[index + 1] = temp;
    }

    @Override
    protected boolean outOfOrder(int index) {
        return array[index] > array[index + 1];
    }
}